var vm = new Vue({
	el: '#app',
	data: {
		items: [],
		loaded: false
	},
	mounted: function() {
		data();
		adminSumOutWallet();
		adminSumOutWallet2();
	}
});
var SearchFromDate, SearchToDate;
var data, obj;

function getTransferRecord() {
	var getTransferRecord = {
		rows: 10,
		page: 1,
		coinId: 9,
		userId: obj.result.id,
		userName: obj.result.userName,
		addr: '',
		status: '',
		startTime: SearchFromDate + ' 00:00:00',
		endTime: SearchToDate + ' 23:59:59'
	}
	$.ajax({
		type: "GET",
		url: ip + "platform/user/userOutWalletList.m",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		data: getTransferRecord,
		success: function(data) {
			$("#row").html('');
			if(data.statusCode == 0) {
				if(data.result.result == '') {
					$("#row").html('<div align="center">暂无记录</div>');
				}
				vm.loaded = true;
				var html = '';
				for(var i = 0; i < (data.result.result).length; i++) {
					var t = data.result.result[i].status;
					var u = data.result.result[i].accountType;
					var remark;
					if(data.result.result[i].remark == null) {
						remark = "暂无备注信息";
					} else {
						remark = data.result.result[i].remark;
					}
					var p, q;
					if(u == 1) {
						q = "可用";
					} else if(u == 2) {
						q = "已释放";
					}
					if(t == 0) {
						p = "待审核";
					} else if(t == 1) {
						p = "成功";
					} else if(t == 2) {
						p = "拒绝";
					} else if(t == 3) {
						p = "撤销";
					} else if(t == 4) {
						p = "处理中";
					} else if(t == 6 || t == 7) {
						p = "发送中";
					}
					html += '<ul class="accordion">' +
						'<li>' +
						'<div class="accordion-tit">' +
						'<div class="weui-cell">' +
						'<div class="weui-cell__bd">' +
						timestampToTime(data.result.result[i].createTime) +
						'</div>' +
						'<div class="weui-cell__ft">' +
						data.result.result[i].num +
						'</div>' +
						'</div>' +
						'</div>' +
						'<div class="weui-cells f15">' +
						'<div class="weui-cell">' +
						'<div class="weui-cell__bd">' +
						'<p>提取数量</p>' +
						'</div>' +
						'<div class="weui-cell__ft">' +
						data.result.result[i].num +
						'</div>' +
						'</div>' +
						'<div class="weui-cell" style="display:block;">' +
						'<div class="weui-cell__bd">' +
						'<p>提取平台钱包地址</p>' +
						'</div>' +
						'<div class="weui-cell__ft" style="font-size:12px;position: absolute;margin-top:-3px;">' +
						data.result.result[i].addr +
						'</div>' +
						'</div>' +
						'<div class="weui-cell">' +
						'<div class="weui-cell__bd">' +
						'<p>提取状态</p>' +
						'</div>' +
						'<div class="weui-cell__ft">' +
						p +
						'</div>' +
						'</div>' +
						'<div class="weui-cell">' +
						'<div class="weui-cell__bd">' +
						'<p>转出类型</p>' +
						'</div>' +
						'<div class="weui-cell__ft">' +
						q +
						'</div>' +
						'</div>' +
						'<div class="weui-cell">' +
						'<div class="weui-cell__bd">' +
						'<p>备注</p>' +
						'</div>' +
						'<div class="weui-cell__ft">' +
						remark +
						'</div>' +
						'</div>' +
						'<div class="weui-cell">' +
						'<div class="weui-cell__bd">' +
						'<p>提取时间</p>' +
						'</div>' +
						'<div class="weui-cell__ft">' +
						timestampToTime(data.result.result[i].updateTime) +
						'</div>' +
						'</div>' +
						'</div>' +
						'</li>' +
						'</ul>';
				}
				$("#row").append(html);
				//列表伸缩
				$('.accordion-tit').click(function() {
					$parent = $(this).parent('li');
					if($parent.hasClass('cur')) {
						$parent.removeClass('cur');
						$parent.siblings().removeClass('cur');
					} else {
						$parent.addClass('cur');
						$parent.siblings().removeClass('cur');
					}
				});
			} else {
				$.toptip(data.resultDesc, 'error');
			}
		}
	});
}
/**
 * 转张记录的累计转张
 */

function data() {
	var myDate = new Date();
	var nowDate = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate();
	SearchFromDate = '1970-01-01';
	SearchToDate = nowDate;
	$("#SearchFromDate").text(SearchFromDate);
	$("#SearchToDate").text(SearchToDate);
	data = localStorage.getItem("data");
	obj = JSON.parse(data);
}

function adminSumOutWallet() {
	var adminSumOutWalletReqbody = {
		coinId: 9,
		userId: obj.result.id,
		userName: obj.result.userName,
		addr: '',
		status: '1',
		startTime: SearchFromDate + ' 00:00:00',
		endTime: SearchToDate + ' 23:59:59'
	}
	$.ajax({
		type: "GET",
		url: ip + "platform/user/userSumOutWallet.m",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		data: adminSumOutWalletReqbody,
		success: function(data) {
			getTransferRecord();
			$("#SearchFromDate").text(SearchFromDate);
			$("#SearchToDate").text(SearchToDate);
			if($("#SearchFromDate").text() == '1970-01-01') {
				$("#SearchFromDate").text("~");
			}
			if(data.result == null) {
				$("#bd").text('0');
			} else {
				$("#bd").text(data.result);
			}
			// 成功之后关掉弹窗
			$(document).on("click", ".weui-btn_plain-confirm", function() {
				$.closePopup("#half");
			});
		}
	});
}

function adminSumOutWallet2() {
	var adminSumOutWalletReqbody2 = {
		coinId: 9,
		userId: obj.result.id,
		userName: obj.result.userName,
		addr: '',
		status: '1',
		startTime: '',
		endTime: ''
	}
	$.ajax({
		type: "GET",
		url: ip + "platform/user/userSumOutWallet.m",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		data: adminSumOutWalletReqbody2,
		success: function(data) {
			if(data.result == null) {
				$("#bbd").text('0');
			} else {
				$("#bbd").text(data.result);
			}
		}
	});
}